<?php
declare (strict_types = 1);

namespace app\home\controller;

use think\facade\View;
use think\Request;

class Goods extends Base
{
    /**
     * 商品列表
     * @return string
     */
    public function list(){

        # 添加搜索条件
        $cate_id = \request()->get('cate_id',0);

        if (!is_numeric($cate_id)) {
          $cate_id = 0;
        }

        $goodsList = \app\home\business\Goods::list($cate_id);
        $category = \app\home\business\Category::info($cate_id);
        View::assign('list',$goodsList);
        View::assign('category',$category);
        return View::fetch();
    }

    /**
     * 商品详情
     */
    public function detail($id){
        $info = \app\home\business\Goods::detail($id);
        View::assign('info',$info);
        return View::fetch();
    }
}
